namespace My
{
    template<class T>
    class weak_ptr
    {
    public:
        weak_ptr()
            :_ptr(nullptr)
        {}

        weak_ptr(const weak_ptr<T>& wp)
            :_ptr(wp._ptr)
        {}

        weak_ptr(const shared_ptr<T>& sp)
            :_ptr(sp.get())
        {}

        weak_ptr<T>& operator=(const shared_ptr<T>& sp)
        {
            _ptr = sp.get();
            return *this;
        }

        T& operator*() { return *_ptr; }
        T* operator->() { return _ptr; }

    private:
        T* _ptr;
    };
}
